import React from 'react';
import {Route} from 'react-router-dom'
import Loadable from 'react-loadable';

const Loading=()=>(<div>loading...</div>);

export function mapRoutes(library){
    let routes=[];
    routes=Object.values(library).map(val => {
        return (
            <Route key={val.path} path={val.path} component={Loadable({
                loader:val.loader,
                loading:Loading
            })}></Route>
        )
    });
    return routes;
}
